<template>
  <div>
      <!-- params传参  ---  url不可见  刷新会丢失 -->
      <div>
        账号:<input v-model="user" type="text">
      </div>
      <div>
        密码:<input v-model="pwd" type="text">
      </div>
       <!-- 编程式params传参 -->
      <!-- <div>
        <button @click="login">登录</button>
      </div> -->

      <!-- 声明式params传参 -->

      <!-- <div>
        <router-link :to="{ name: 'List', params: {
          user,
          pwd
        } }" tag="button">
          登录2
        </router-link>
      </div> -->

      <!-- 下午 -->
      <button @click="login2">登录</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      user: "",
      pwd: ""
    }
  },
  methods: {
    login() {
      // params传参
      this.$router.push({
        // 匹配路由表中name字段
        name: "List",
        params: {
          user: this.user,
          pwd: this.pwd
        }
      })
    },
    login2() {
      sessionStorage.setItem("token", true)
      this.$router.push('/home/my')
    }
  }
}
</script>

<style>

</style>